package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzShijuan;
import com.ruoyi.system.service.IDzShijuanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试卷信息Controller
 * 
 * @author ruoyi
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/system/shijuan")
public class DzShijuanController extends BaseController
{
    @Autowired
    private IDzShijuanService dzShijuanService;

    /**
     * 查询试卷信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:shijuan:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzShijuan dzShijuan)
    {
        startPage();
        List<DzShijuan> list = dzShijuanService.selectDzShijuanList(dzShijuan);
        return getDataTable(list);
    }

    /**
     * 导出试卷信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:shijuan:export')")
    @Log(title = "试卷信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzShijuan dzShijuan)
    {
        List<DzShijuan> list = dzShijuanService.selectDzShijuanList(dzShijuan);
        ExcelUtil<DzShijuan> util = new ExcelUtil<DzShijuan>(DzShijuan.class);
        util.exportExcel(response, list, "试卷信息数据");
    }

    /**
     * 获取试卷信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shijuan:query')")
    @GetMapping(value = "/{sjId}")
    public AjaxResult getInfo(@PathVariable("sjId") Long sjId)
    {
        return AjaxResult.success(dzShijuanService.selectDzShijuanBySjId(sjId));
    }

    /**
     * 新增试卷信息
     */
    @PreAuthorize("@ss.hasPermi('system:shijuan:add')")
    @Log(title = "试卷信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzShijuan dzShijuan)
    {
        return toAjax(dzShijuanService.insertDzShijuan(dzShijuan));
    }

    /**
     * 修改试卷信息
     */
    @PreAuthorize("@ss.hasPermi('system:shijuan:edit')")
    @Log(title = "试卷信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzShijuan dzShijuan)
    {
        return toAjax(dzShijuanService.updateDzShijuan(dzShijuan));
    }

    /**
     * 删除试卷信息
     */
    @PreAuthorize("@ss.hasPermi('system:shijuan:remove')")
    @Log(title = "试卷信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sjIds}")
    public AjaxResult remove(@PathVariable Long[] sjIds)
    {
        return toAjax(dzShijuanService.deleteDzShijuanBySjIds(sjIds));
    }
}
